﻿using System;
using System.IO;
using System.Linq;
using Excel4SmallBasic;

class Program
{
    static void Main(string[] args)
    {
        var baseDir = AppDomain.CurrentDomain.BaseDirectory;
        var path1 = Path.Combine(baseDir, "Book1.xls");
        var path2 = Path.Combine(baseDir, "Book2.xls");
        var path3 = Path.Combine(baseDir, "Book3.xls");
        
        var result = Excel.ReadCell(path1, "Sheet1", 2, 1);
        Console.WriteLine("[{0}]", result.ToString());
        
        var result2 = Excel.ReadCell(path1, "Sheet1", 2, 2);
        Console.WriteLine("[{0}]", result2.ToString());
        
        var result3 = Excel.ReadCell(path2, "Sheet1", 2, 1);
        Console.WriteLine("[{0}]", result3.ToString());

        Enumerable.Range(1, 10).ToList().ForEach(n =>
        {
            result3 = Excel.ReadCell(path3, "Sheet1", 3, 1);
            Console.WriteLine("[{0}]", result3.ToString());

            result3 = Excel.ReadCell(path1, "Sheet1", 3, 3);
            Console.WriteLine("[{0}]", result3.ToString());

            Excel.WriteCell(path3, "Sheet2", 2, 3, DateTime.Now.Second);
        });

        Excel.CloseAll();
        Console.WriteLine("Complete.");
        Console.ReadKey(true);
    }
}
